# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=lua-redis
_pkgname=redis-lua
_luaversions="5.1 5.2 5.3"
pkgver=2.0.4
pkgrel=4
pkgdesc="A Lua client library for the redis key value storage system"
url="https://github.com/nrk/redis-lua"
arch="noarch"
license="MIT"
depends="lua-socket"
options="!check"
source="$pkgname-$pkgver.tar.gz::https://github.com/nrk/redis-lua/archive/v$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver
for _v in $_luaversions; do
	makedepends="$makedepends lua$_v-dev"
	subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
done

package() {
	mkdir -p "$pkgdir"
}

_subpackage() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc (for Lua $lver)"
	depends="lua$lver lua$lver-socket"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"
	local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_pkgname/$pkgver-1"

	install -Dm644 $builddir/src/redis.lua \
		"$subpkgdir"/usr/share/lua/"$lver"/redis.lua

	mkdir -p "$rockdir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="
8e1266601881b0404aa1d771acc486b09a3752f901d4eec04c40912556d2ffe6eb24045d257193c7229fdfa48530a754ce267466f258a9618a30e3ab7ba9e1bc  lua-redis-2.0.4.tar.gz
"
